package com.example.qianfeng.image.util;

import org.apache.commons.codec.binary.Base64;

public class BASE64 {
    public static byte[] decode(String data){
        try {
            byte[] bytes = Base64.decodeBase64(data);
            return bytes;
        }catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException("base64 加密失败！");
        }
    }

    public static String encode(byte[] data){
        try {
            String s = Base64.encodeBase64String(data);
            return s;
        }catch (Exception e){
            e.printStackTrace();
            throw new RuntimeException("base64 加密失败！");
        }
    }
}
